package com.miplus.ccrm.core.service.conf;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.miplus.ccrm.core.pojo.SipRegistrations;
import com.miplus.ccrm.core.service.conf.SipRegistrationsService;
import com.miplus.ccrm.core.mapper.SipRegistrationsMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Yaohui
* @description 针对表【sip_registrations】的数据库操作Service实现
* @createDate 2025-03-28 16:51:42
*/
@Service
public class SipRegistrationsServiceImpl extends ServiceImpl<SipRegistrationsMapper, SipRegistrations>
    implements SipRegistrationsService{

    @Override
    public String getSipReg(String sipUser) {
        List<SipRegistrations> list = query().select("fun_getnames('CONFIG.SIP.REG',server_host) AS server_host").eq("sip_user", sipUser).orderByDesc("expires").list();

        if(list==null || list.size()==0){
            return null;
        }
        return list.get(0).getServerHost();
    }
}

